﻿using RM.Insfrastructure.EntityFactoryFramework;
using RM.Model.Rooms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RM.Insfrastructure.Respositories.Rooms
{
    internal class RoomFactory: IEntityFactory<Room>
    {

        #region field names
        internal static class FieldNames
        {
            public const string id = "id";
            public const string type = "type";
            public const string dateCreate = "date_create";

            public const string name = "name";
        }
        #endregion


        #region ientityfactory<room> members
        public Room BuildEntity(SqlDataReader reader) {
            Room room = new Room(reader[FieldNames.id]);
            room.Type = new RoomType(reader[FieldNames.type]);
            room.DateCreate = new DateTime(); // edit me
            return room;
        }

        public RoomType BuildRoomType(SqlDataReader reader) {
            return new RoomType(reader[FieldNames.id], reader[FieldNames.name].ToString());
        }
        #endregion



    }
}
